package main

import (
	"fmt"
	"net"
	"time"
)

func main() {
	// 连接远程主机
	fmt.Println("start time: ", time.Now())
	conn, err := net.Dial("tcp", "172.16.39.169:40003")
	if err != nil {
		fmt.Println("Error connecting:", err)
		return
	}
	fmt.Println(" connection successfully!")
	defer conn.Close()

	// 发送用户名和密码
	username := "root"
	password := "root"
	fmt.Fprintf(conn, "USER %s\r\n", username)
	fmt.Fprintf(conn, "PASS %s\r\n", password)

	// 读取响应
	var buf [512]byte
	n, err := conn.Read(buf[:])
	if err != nil {
		fmt.Println("Error reading:", err)
		return
	}
	fmt.Println(string(buf[:n]))
	fmt.Println("end time : ", time.Now())
}
